<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>登陆</title>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <link rel="stylesheet" type="text/css" th:href="@{/static/lib/bootstrap/bootstrap.min.css}" />
    <link rel="stylesheet" type="text/css" th:href="@{/static/lib/bootstrap/style.min.css}" />
    <link rel="stylesheet" type="text/css" th:href="@{/static/lib/bootstrap/font-awesome.min.css}" />

    <script type="text/javascript" th:src="@{/static/lib/jquery/1.9.1/jquery.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/lib/bootstrap/bootstrap.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/js/layui/layui.all.js}"></script>
    <link rel="stylesheet" type="text/css" th:href="@{/static/js/layui/css/layui.css}" />
    <script type="text/javascript"  th:inline="javascript">
        /*<![CDATA[*/
       var rootPath = /*[[@{/}]]*/ '';
        /*]]>*/
        function flushImage() {
            $("#imageCode").attr("src",rootPath+"login/imageCode?t="+new Date().getTime())
        }
        
        function login() {
            var loginName = $("#loginName").val();
            var password = $("#password").val();
            var verifyCode = $("#verifyCode").val();
            if(!loginName){
                layer.alert("登录名不能为空");
                return;
            }
            if(!password){
                layer.alert("密码不能为空");
                return;
            }
            if(!verifyCode){
                layer.alert("图形验证码不能为空");
                return;
            }
            $.post(rootPath+"login/login",$("#loginForm").serialize(),function (data) {
                if (data.code==0){
                       window.location.href=rootPath+"index/gotoIndex"
                }else{
                    layer.alert(data.message);
                    flushImage()
                }
            })
        }
    </script>
</head>
<body>
<div class="row">
    <div id="content" class="col-sm-12 full">
        <div class="row">
            <div class="login-box">
                <div class="header">
                    代码自动生成器
                </div>
                <form id="loginForm" method="post">
                    <div class="form-group">
                        <div class="controls">
                            <div class="input-group">
                                <input type="text" class="form-control" id="loginName" name="loginName"
                                       placeholder="请输入用户名"
                                       required data-bv-notempty-message="请输入用户名" value="ztp"/>
                                <span class="input-group-addon"><i class="fa fa-user"></i></span>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="controls">
                            <div class="input-group">
                                <input type="password" class="form-control" id="password" name="password"
                                       placeholder="密码" autocomplete="new-password" value="111111"
                                       required data-bv-notempty-message="请输入密码"/>
                                <span class="input-group-addon"><i class="fa fa-key"></i></span>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="controls">
                            <div class="input-group">
                                <span class="input-group-addon">验证码：</span>
                                <input id="verifyCode" class="form-control" name="verifyCode" type="text" placeholder="&nbsp;&nbsp;请输入验证码" style="width:180px;" />
                                <img class="verify-code" th:src="@{/login/imageCode}" title="点击更换验证码" onclick="flushImage()" id="imageCode"/>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <button type="button" onclick="login()" class="btn btn-lg btn-primary col-xs-12">登　录</button>
                    </div>
                </form>
            </div>
        </div>
        <!--/row-->
    </div>

</div>
<!--/row-->
<!--/container-->
</body>
</html>